package yagwl.client.model;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Base class for DTO classes; defines id (key), label, and a map for name-value
 * pairs
 */
@SuppressWarnings("serial")
public class ItemDTO implements Serializable {

  private String id;
  private String label;
  private boolean selected;
  private Map<String, String> map = new HashMap<String, String>();

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setLabel(String label) {
    this.label = label;
  }

  public String getLabel() {
    return label;
  }

  /**
   * Returns true if selected by user on the UI.
   */
  public boolean isSelected() {
    return selected;
  }

  /**
   * Sets to true by widgets like DataTable, if the object is selected by the
   * user on the UI.
   */
  public void setSelected(boolean selected) {
    this.selected = selected;
  }

  public void put(String key, String value) {
    map.put(key, value);
  }

  public void put(String key, int value) {
    map.put(key, Integer.toString(value));
  }

  public String get(String key) {
    return map.get(key);
  }

  public Map<String, String> getMap() {
    return map;
  }

}
